package io.finer.erp.jeecg.bas.service.impl;

import io.finer.erp.jeecg.bas.entity.ZzDevice;
import io.finer.erp.jeecg.bas.mapper.ZzDeviceMapper;
import io.finer.erp.jeecg.bas.service.IZzDeviceService;

import java.util.List;

import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.MaterialConstant;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;

import cn.hutool.core.lang.UUID;

/**
 * @Description: 设备列表
 * @Author: jeecg-boot
 * @Date:   2020-09-01
 * @Version: V1.0
 */
@Service
public class ZzDeviceServiceImpl extends ServiceImpl<ZzDeviceMapper, ZzDevice> implements IZzDeviceService {

	@Override
	public Result<?> getOrderDevice(Integer type) {
		// TODO Auto-generated method stub
		if(null == type) {
			return Result.error("请选择工序");
		}
		List<String> list = Lists.newArrayList();
		switch(type.intValue()) {
		case 1:
			list.add(MaterialConstant.PROCESS_COMPOUND);
			break;
		case 2:
			list.add(MaterialConstant.PROCESS_PART);
			break;
		case 3:
			list.add(MaterialConstant.PROCESS_CUTTING_BIG);
			list.add(MaterialConstant.PROCESS_CUTTING_NORMAL);
			break;
		case 4:
			list.add(MaterialConstant.PROCESS_ZJ);
			break;
		default:
			list.add(UUID.randomUUID().toString());	
		}
		LambdaQueryWrapper<ZzDevice> query = new LambdaQueryWrapper<>();
		query.in(ZzDevice::getDeviceType, list);
		List<ZzDevice> devices = list(query);
		return Result.ok(devices);
	}

}
